home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 1 Issue 2
/
PDCD-1 - Issue 02.iso
/
_utilities
/
utilities
/
004
/
gamesuit
/
!Stasis
/
Alien
/
AlSource
next >
Wrap
Text File
|
1994-08-05
|
7KB
|
324 lines
#type &ffa
#name StasisDVox
#base 0
#include ASMLib:Standard
#set Service_PsychoStarting=&80300
#set Service_PsychoDying =&80301
#set Service_UKStasisFormat=&80310
#set Service_StasisSave =&80311
#set Service_StasisIdentify=&80312
#set stasis_alien =1
#set dvox_filetype =&108
struct dvox {
.type DCB 0
.flags DCB 0
.pitch DBB 2
.dataofs DCD 0
.repstart DCD 0
.repend DCD 0
.id DCD 0
.version DCD 0
.upcall DCD 0
.len DCD 0
.sizeof
}
.ModuleHeader
.start
DCD 0
DCD init
DCD final
DCD service
DCD title
DCD help
DCD helptable
DCD 0
DCD 0
DCD 0
DCD 0
.title
DCB "StasisDVox"
DCB 0
ALIGN
.help
DCB "Stasis Alien",9,"1.00 (24 Jul 1994) - For DataVox format samples"
DCB 0
ALIGN
.helptable
DCB "StasisDVox"
DCB 0
ALIGN
DCD 0
DCD 0
DCD 0
DCD dvoxhelp
DCD 0;End Marker
.dvoxhelp
DCB "This module allows Stasis to handle DataVox type 3 files. The samples can be replayed, and saved by the *StasisSave DataVox command.",0
ALIGN
.dvoxid
DCB "DVOX"
.service
;R12 is the only register we may corrupt in a service call
SUBS R12,R1,#&80000
MOVMI PC,R14
SUB R12,R12,#&300
TEQ R12,#Service_UKStasisFormat-&80300
TEQNE R12,#Service_StasisIdentify-&80300
TEQNE R12,#Service_StasisSave-&80300
MOVNE PC,R14
TEQ R12,#Service_StasisIdentify-&80300
BEQ identify
TEQ R12,#Service_StasisSave-&80300
BEQ save
.ukformat
STMFD R13!,{R3-R4,R14}
LDR R3,[R0,#dvox.id]
LDR R4,dvoxid
CMP R3,R4
LDMNEFD R13!,{R3-R4,PC}^
;identified a DataVox sample.
;we could also check R2 = &108 (the filetype)
;Not all datavox samples are in logarithmic format.
;This module must convert it if it isn't.
;That's what typeconv does.
BL typeconv
ADR R0,alienblock
MOV R1,#0; claim service call
LDMFD R13!,{R3-R4,PC}
.typeconv
STMFD R13!,{R0-R5,R14}
LDRB R1,[R0,#dvox.type]; note byte load
MOV R2,#0
CMP R1,#1;datavox linear unsigned type
ADREQ R2,convtab1
CMP R1,#2;datavox linear signed type
ADREQ R2,convtab2
CMP R1,#3;datavox Ulaw type
ADREQ R2,convtab3
CMP R2,#0
LDMEQFD R13!,{R0-R5,PC}
LDR R3,[R0,#dvox.dataofs]
ADD R3,R3,R0
LDR R4,[R0,#dvox.len]
ADD R4,R4,R0
.loop
LDRB R5,[R3] ;get data from dvox sample
LDRB R5,[R2,R5] ;look it up in the table
STRB R5,[R3],#1 ;store it back, add 1 to R3
CMP R3,R4
BLT loop
LDMFD R13!,{R0-R5,PC}
.convtab1
INCBIN Alien:convtab1
.convtab2
INCBIN Alien:convtab2
.convtab3
INCBIN Alien:convtab3
ALIGN
.alienblock
DCB "StAl"; ID Word - required - used to check if the block is valid.
DCD getinfo-alienblock;get info routine
DCD putinfo-alienblock;put info routine
DCD 0 ;release routine (we don't have one)
DCD 0 ;must be zero
DCD 0 ;for future use
DCD 0 ;for future use
DCD name1-alienblock
DCD formatname-alienblock
DCD dvox_filetype
DCD title-alienblock
DCD 0
ALIGN
;The info routine is entered with
;R0 points to the stasis slot decription block
;R1 points to your sample
;The file length as loaded may be accessed by LDR R0,[R10,#4]
;The info entry should return:
;R1=name *
;R2=length
;R3=finetune * &4000=default, &2000=1 octave lower, &8000=1 octave higher etc
;R4=repofs *
;R5=replen *
;R6=datastart
;R7=volume *
;R8=special (return R8=0)
; *= may return zero if not supported
;Most of this routine deals with the DVox format's idiosyncrasies
.getinfo
MOV R11,R1;our sample address
MOV R1,#0; sample name - not supported by DVOX samples
LDR R2,[R11,#dvox.len]; file length
MOV R3,#0;finetune/volume value - not supported
MOV R4,#0
MOV R5,#0
LDRB R7,[R11,#dvox.flags] ;ignore repeat offset unless timed play is set
TST R7,#0
LDRNE R4,[R11,#dvox.repstart]
;we need the repeat offset
LDRNE R5,[R11,#dvox.repend]
;we need the repeat length
SUBNE R5,R5,R4 ; that's the repeat length sorted out
LDR R6,[R11,#dvox.dataofs]
SUB R2,R2,R6 ; convert file length to sample length
SUBNE R4,R4,R6 ; that's the repeat offset
ADD R6,R6,R11 ; R6 is the address of the sample data
MOV R7,#0
MOV R8,#0
MOV PC,R14
.putinfo
MOV R11,R1
;LDMFD R13,{R1} ;no writeback
LDR R6,[R11,#dvox.dataofs]
ADD R2,R2,R6 ;put the values into datavox style
ADD R4,R4,R6
ADD R5,R5,R4
TST R8,#1<<2
STRNE R2,[R11,#dvox.len]
TST R8,#1<<4
STRNE R4,[R11,#dvox.repstart]
TST R8,#1<<5
STRNE R5,[R11,#dvox.repend]
TST R8,#1<<6
SUBNE R6,R6,R11
STRNE R6,[R11,#dvox.dataofs]
AND R0,R8,#%10001010 ;what we don't support
MOV PC,R14
.identify
ADD R0,R0,#1
CMP R2,#0
MOVEQ PC,R14
ADR R12,alienblock
STR R12,[R2],#4
MOV PC,R14
;On entry to a save routine, R0 is the slot number (for us to pass
;to Stasis_GetSlotInfo.
;R2 points to the filename
;R3 points to the namecheck routine in Stasis which compares the name
;pointed to by R1 to that entered at the command line
;We pass on the Service call if we don't recognise the save type
;ie return with MOV PC,R14 with registers unchanged.
;If we want to save in our format we return with
;R0 preserved.
;R1=0 to claim the service call
;R2 points to a filled-in header block
;R3 is the length of the header block
;R4 is the filetype
;Stasis will add the sample data in logarithmic format after the header
;
;Otherwise return with R2=0 after carrying out the whole save process
;yourself.
;To return an error, return with R2=1 and R0 pointing to an error block.
.dvoxformat
;read with reference to the dvox struct at the start of this file
DCB 0
DCB 0
DCB &17
DCB &7E
DCD &20
DCD 0
DCD 0
DCB "DVOX"
DCD 3
DCD 0
DCD 0
.save
STMFD R13!,{R1,R14}
ADR R1,name1
MOV R14,PC
MOV PC,R3 ;BL to R3
ADRNE R1,name2
MOVNE R14,PC
MOVNE PC,R3
LDMFD R13!,{R1,R14}
MOVNES PC,R14;return if no match
STMFD R13!,{R0,R5-R10,R14}
SWI Stasis_GetSlotInfo
ADR R10,dvoxformat
ADD R2,R2,#dvox.sizeof ;fill in our header
STR R2,[R10,#dvox.len]
ADD R5,R5,R4 ;R5 is now the repeat end
ADD R4,R4,#dvox.sizeof
STR R4,[R10,#dvox.repstart]
ADD R5,R5,#dvox.sizeof
STR R5,[R10,#dvox.repend]
MOV R6,#dvox.sizeof
STR R6,[R10,#dvox.dataofs]
MOV R1,#0
MOV R2,R10
MOV R3,#dvox.sizeof
MOV R4,#dvox_filetype
LDMFD R13!,{R0,R5-R10,PC}
;return and let Stasis do the rest
.init ;My standard init/final service calls.
STMFD R13!,{R0-R3,R14}
ADR R0,start
MOV R1,#Service_PsychoStarting
MOV R2,#0; the R12 value
MOV R3,stasis_alien
ADR R4,alienblock
SWI OS_ServiceCall
CMP R1,#0
LDMFD R13!,{R0-R3,R14}
ADREQ R0,initerrtext
ORRVS R14,R14,#1<<28
MOVS PC,R14
.final
STMFD R13!,{R0-R3,R14}
ADR R0,start
MOV R1,#Service_PsychoDying
MOV R2,#0
MOV R3,stasis_alien
ADR R4,alienblock
SWI OS_ServiceCall
CMP R1,#0
LDMFD R13!,{R0-R3,R14}
ADREQ R0,finalerrtext
ORRVS R14,R14,#1<<28
MOVS PC,R14
.initerrtext
DCD &809DFE
DCB "StasisDVox : Initialisation veto",0
ALIGN
.finalerrtext
DCD &809DFF
DCB "StasisDVox : RMKill veto",0
.name1
DCB "DataVox",0
.name2
DCB "DVox",0
.formatname
DCB "DataVox format 3",0
ALIGN